class Section
  include Mongoid::Document

  field :name, type: String
  belongs_to :competition
  has_many :question_types, dependent: :restrict
  has_many :question_lists, dependent: :restrict

  field :default_question_type_id, type: Moped::BSON::ObjectId

  field :question_count, type: Integer, default: 0

  def default_question_type
    #self.question_types.map{|t|t.name}.join('\n')
    #self.question_types.first
    QuestionType.find(self.default_question_type_id)
  end
end
